
package org.apache.solr.handler.loader;

import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.ContentStream;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.update.processor.UpdateRequestProcessor;

/**
 * Load a {@link org.apache.solr.common.util.ContentStream} into Solr
 *
 * This should be thread safe and can be called from multiple threads
 */
public abstract class ContentStreamLoader {

    /**
     * This should be called once for each RequestHandler
     */
    public ContentStreamLoader init(SolrParams args) {
        return this;
    }

    public String getDefaultWT() {
        return null;
    }

    /**
     * Loaders are responsible for closing the stream
     *
     * @param req The input {@link org.apache.solr.request.SolrQueryRequest}
     * @param rsp The response, in case the Loader wishes to add anything
     * @param stream The {@link org.apache.solr.common.util.ContentStream} to add
     * @param processor The {@link UpdateRequestProcessor} to use
     */
    public abstract void load(SolrQueryRequest req, SolrQueryResponse rsp, ContentStream stream, UpdateRequestProcessor processor) throws Exception;
}
